package org.qengine.utils.Deduplicator;

import org.apache.commons.math3.linear.RealVector;

public class SimilarityCalculator {
    // 计算余弦相似度
    public static double cosineSimilarity(RealVector vector1, RealVector vector2) {
        double dotProduct = vector1.dotProduct(vector2);
        double norm1 = vector1.getNorm();
        double norm2 = vector2.getNorm();
        return dotProduct / (norm1 * norm2);
    }
}
